﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Template/Site_Main.Master" AutoEventWireup="true"
    CodeBehind="indicators.aspx.cs" Inherits="RegisterationSystem.Space_Education.indicators" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
      <!--
        $(function () {
            //设置导航位置
            setLocalToParent();
            //初始化企业用户数据列表控件
            $("#dg").datagrid({
                idField: "id",      //标识字段,主键
                url: "../SyncService/GetDataList.ashx?action=GetSchoolList",
                pagination: false,   //是否开启分页
                rownumbers: true,   //行号
                pageSize: 10,
                pageNumber: 1,
                //selectOnCheck:false,
                //checkOnSelect:false,
                columns: [[
                            { field: 'ck', checkbox: true },
                            { field: 'name', title: '学校名称', width: 200, align: 'center' },
                            { field: 'count', title: '计划招生数', width: 100, align: 'center', editor: { type: 'numberbox', options: { max: 10000}} },
                            { field: 'ainfo', title: 'A类学生登记说明', width: 230, align: 'center', editor: { type: 'validatebox'} },
                            { field: 'binfo', title: 'B类学生登记说明', width: 230, align: 'center', editor: { type: 'validatebox'} },
                            { field: 'cinfo', title: 'C类学生登记说明', width: 230, align: 'center', editor: { type: 'validatebox'} }
                         ]],
                onClickRow: function (index, row) {
                    if (editIndex != index) {
                        if (endEditing()) {
                            $('#dg').datagrid('beginEdit', index);
                            editIndex = index;
                        } else {
                            $('#dg').datagrid('selectRow', editIndex);
                        }
                    }
                }
            })
        });
        //-->
        //选择下一行的时候，修改前行
        var editIndex = undefined;
        function endEditing() {
            if (editIndex == undefined) { return true }
            if ($('#dg').datagrid('validateRow', editIndex)) {
                var ed = $('#dg').datagrid('getEditor', { index: editIndex, field: 'id' });
                //var productname = $(ed.target).combobox('getText');
                //$('#tt').datagrid('getRows')[editIndex]['productname'] = productname;
                $('#dg').datagrid('endEdit', editIndex);
                editIndex = undefined;
                return true;
            } else {
                return false;
            }
        }
        //批量选择(修改)
        function Getcheckbox() {
            //id集合
            var ids = "";
            //count集合
            var counts = "";
            //A集合
            var acounts = "";
            //B集合
            var bcounts = "";
            //C集合
            var ccounts = "";
            //获取选择集合
            var rows = $('#dg').datagrid('getSelections');
            if (rows.length == 0) {
                alert("请选择行");
                return;
            }
            //遍历选择行
            for (var i = 0; i < rows.length; i++) {
                //修改未编辑完的行
                $('#dg').datagrid('endEdit', editIndex);
                ids += rows[i].id + ",";
                counts += rows[i].count + ",";
                acounts += rows[i].ainfo + "|";
                bcounts += rows[i].binfo + "|";
                ccounts += rows[i].cinfo + "|";
            }
            $.messager.confirm('提示', '确认修改？', function (r) {
                if (r) {
                    $.post(location.href, { "action": "upd", "id": ids, "count": counts, "acounts": acounts, "bcounts": bcounts, "ccounts": ccounts }, function (data) {
                        $.messager.alert("消息提示", "学校指标修改成功！");
                        $('#dg').datagrid('reload');
                    });
                }
            });
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Place_Local" runat="server">
    <div class="localTitle">
        <a>学校指标管理</a>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="loadheight">
        <table width="100%%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td bgcolor="#FFFFFF">
                    <table width="100%%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td>
                                <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                </table>
                            </td>
                        </tr>
                    </table>
                    <table width="100%%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td class="cen_R_top">
                                <strong>学校指标管理</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <!-- 创建数据列表控件 -->
                                <table id="dg">
                                </table>
                                <div style="margin-top: 10px;">
                                </div>
                                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td align="left">
                                            <input type="button" name="button2" id="button2" value="修改" class="anniu" width="73px"
                                                height="23px" onclick="Getcheckbox();" />
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
